package com.Maykk.Demo01;

/**
 * @ClassName Demo03
 * @Description: TODO Int \ String 类型转换
 * @Author: MaykkSTAR@163.com
 * @DATE: 2023/4/14
 */
public class Demo03 {
    public static void main(String[] args) {
        // =========== int to String ==============
        int num = 10000;
        // 方法1
        String numStr01 = Integer.toString(num);
        System.out.println("1.int to String: " + numStr01);
        // 方法2
        String numStr02 = String.valueOf(num);
        System.out.println("2.int to String: " + numStr02);
        // 方法3
        String intToString = "3.int to String: " + num;
        System.out.println(intToString);
        System.out.println();

        // ========== String to int ===============
        String str = "123";
        // 方法1
        Integer str01 = new Integer(str);
        System.out.println("1.String to int: " + str01 + 1);
        // 方法2
        Integer str02 = Integer.valueOf(str);
        System.out.println("2.String ring to int: " + str02 + 1);
    }
}
